/* 
利用object.setprototypeof（Dog.prototype，Animal.prototype）把dog的隐式原型设置成animal的原型
*/

function Animal(type, name, age, sex) {
    this.type = type;
    this.name = name;
    this.age = age;
    this.sex = sex;
}


Animal.prototype.print = function () {
    console.log(`【种类】：${this.type}`);
    console.log(`【名字】：${this.name}`);
    console.log(`【年龄】：${this.age}`);
    console.log(`【性别】：${this.sex}`);
}



// 子类
function Dog(name, age, sex) {
    Animal.call(this, '犬类', name, age, sex)
}

/* 子类的原型指向animal的原型 */
Object.setPrototypeOf(Dog.prototype, Animal.prototype)



const d = new Dog("旺财", 5, "公")
d.print
console.log(d);


